package 工厂方法模式;

import 简单的工厂模式.工厂模式demo.计算器.Add;
import 简单的工厂模式.工厂模式demo.计算器.Div;
import 简单的工厂模式.工厂模式demo.计算器.Mul;
import 简单的工厂模式.工厂模式demo.计算器.Operation;
import 简单的工厂模式.工厂模式demo.计算器.Sub;

/**
 * @author zyl
 * @Description
 * @since 2024/1/3 13:17
 */

public class OperationFactory {
    Operation operation = null;
    IFactory iFactory = null;
    public Operation creatOperation(String operator){
        switch (operator){
            case "+":
                iFactory = new AddFactory();
                break;
            case "-":
                iFactory = new SubFactory();
                break;
            case "*":
                iFactory = new MulFactory();
                break;
            case "/":
                iFactory = new DivFactory();
                break;
        }
        operation = iFactory.creatOperation();
        return this.operation;
    }
}
